/**
 * 
 */
package org.seginfo.httpfuzzer.header.impl;

import org.seginfo.httpfuzzer.header.AttackStrategy;
import org.seginfo.httpfuzzer.header.HeaderPropertyImpl;

/**
 * @author Administrador
 *
 */
public class IfNoneMatch extends HeaderPropertyImpl {
	
	private static final String NAME = "If-None-Match";
	private static final String VALID = "*";
	//private static final String WILDCARD = "*/*";
	private static final int BAD_STRING_MIN_LENGTH = 1024;
	private static final int BAD_STRING_LENGTH = 2000;

	/**
	 * @param attackStrategy
	 */
	public IfNoneMatch(AttackStrategy attackStrategy) {
		super(attackStrategy);
		this.value = this.generateValue();
	}

	/**
	 * @see org.seginfo.httpfuzzer.header.HeaderPropertyImpl#getName()
	 */
	public String getName() {
		return NAME;
	}

	/**
	 * @return
	 */
	private String generateValue() {
		
		String rv="";

		double p = Math.random();
		
		if (p<0.05) {
			rv = VALID;	
		}
		else if (p<0.1)
		{
			rv = "W/xyzz";
		}
		else
		{
			p = Math.random();
			if (p<0.5)
			{
				rv += "W/";
			}
			rv += attackStrategy.getStringAttack(BAD_STRING_MIN_LENGTH, BAD_STRING_LENGTH);
		}
		return rv;
	}
}
